<template>
  <basic-container>
    <div>
      <m-s-search @searchClick="v=>{queryForm=v,page.currentPage=1,getList()}" :list="signatureTemplateManageOption.column"></m-s-search>
    </div>
    <avue-crud :option="signatureTemplateManageOption"
               :table-loading="loading"
               :data="data"
               @selection-change="v=>selection=v"
               @current-change="currentChange"
               @size-change="sizeChange"
               ref="crud"
               :page.sync="page">
      <template slot="menuLeft" slot-scope="{size}">
        <el-button :size="size" type="primary"
                   @click="addToTabsList('签名模板',{oid:-1},'signatureTemplateManageTemp','open'),openDraw()">
          创建
        </el-button>
        <el-button :size="size" :disabled="selection.length===0" @click="remove(selection)">删除
        </el-button>
        <el-button :size="size" :disabled="selection.length===0"
                   @click="start_stop(selection,'start')">
          启用
        </el-button>
        <el-button :size="size" :disabled="selection.length===0"
                   @click="start_stop(selection,'stop')">
          停用
        </el-button>
      </template>

      <template slot="nameCn" slot-scope="{row}">
        <span class="column-btn"
              @click="addToTabsList(row.name+'签名模板',row,'signatureTemplateManageTemp','view'),openDraw()">
          {{ row.nameCn }}
        </span>
      </template>

      <template slot="menu" slot-scope="{row}">
        <el-button type="text"
                   @click="addToTabsList(row.name+'签名模板',row,'signatureTemplateManageTemp','view'),openDraw()">
          查看详情
        </el-button>
        <el-button type="text"
                   @click="addToTabsList(row.name+'签名模板',row,'signatureTemplateManageTemp','edit'),openDraw()">
          修改
        </el-button>
        <el-button type="text" :disabled="row.checkState === 1" @click="checkIn(row)">检入</el-button>
        <el-button type="text" :disabled="row.checkState === 1" @click="unCheckOut(row)">撤销检出</el-button>
        <el-button type="text"
                   @click="addToTabsList(row.name+'签名模板预览',row,'signatureViewTemp','view'),openDraw()">
          预览
        </el-button>
      </template>
    </avue-crud>

    <ms-drawer @refresh="getList()" :resize="false" ref="md" :visible.sync="visible"
               :tab-list.sync="tabsList"></ms-drawer>
  </basic-container>
</template>

<script>
import MSSearch from "@/DMDComponents/MSSearch.vue";
import commonJs from "@/util/commonJs";

export default {
  name: "signatureTemplateManage",
  components: {MSSearch},
  inject: ["signatureTemplateManageOption"],
  mixins: [commonJs],
  methods: {
    openDraw() {
      this.$refs["md"].ms$set("fillScreen", true);
    },
  }
}
</script>

<style scoped lang="scss">
.ms-dialog {
  top: 0;
  left: 0;
  position: fixed;
  overflow-y: scroll;
  width: 100vw;
  height: 100vh;
  z-index: 99;
  background: white;
}
</style>
